package com.horse.cloud.boss.controller;

import com.horse.cloud.boss.service.GatewayService;
import com.horse.cloud.data.domain.gateway.BusinessSystemBo;
import com.horse.cloud.data.domain.gateway.BusinessSystemQueryBo;
import com.horse.cloud.data.domain.gateway.GatewayServerQueryBo;
import com.horse.cloud.framework.base.BaseController;
import com.horse.cloud.framework.general.response.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @create : Created by intelliJ IDEA 16.1.3
 * @author : bing.Pan
 * @e-mail : 15923508369@163.com
 * @gmdate : 2018/2/4 21:34
 * @sidesc :
 */

@Api(value = "GatewayController",description = "cloud-gateway 网关应用接口")
@RestController
@RequestMapping(value = "/gateway")
public class GatewayController extends BaseController {

    @Autowired private GatewayService gatewayService;


    @ApiOperation(value = "查询业务系统",notes = "根据Id查询业务系统",response = Response.class)
    @ApiImplicitParams(
            @ApiImplicitParam(name = "id", value = "数据库主键", required = true, dataType = "String", paramType = "query")
    )
    @PostMapping(value = "/findBussinessSystemById")
    public Response findBussinessSystemById(String id){
        return gatewayService.findBussinessSystemById(id);
    }


    @ApiOperation(value = "/新增或修改业务系统",notes = "根据是否传入ID值判断是否是新增或修改业务系统",response = Response.class)
    @PostMapping(value = "/addAndUpdate")
    public Response addAndUpdate(BusinessSystemBo businessSystemBo){
        return gatewayService.addAndUpdate(businessSystemBo);


    }

    @ApiOperation(value = "/删除业务系统",notes = "根据是否传入ID值删除业务系统",response = Response.class)
    @PostMapping(value = "/deleteBusinessSystem")
    public Response deleteBusinessSystem(String id){
        return gatewayService.deleteBusinessSystem(id);
    }


    @ApiOperation(value = "查询业务系统列表",notes = "根据条件查询服务网关业务系统列表",response = Response.class)
    @PostMapping(value = "/businessSystemList")
    public Response businessSystemList(BusinessSystemQueryBo businessSystemQueryBo){
        return gatewayService.businessSystemList(businessSystemQueryBo);
    }





    @ApiOperation(value = "查询服务列表", notes = "根据条件查询服务网接口列表",response = Response.class)
    @PostMapping(value = "/serverList")
    public Response serverList(GatewayServerQueryBo gatewayServerQueryBo){
        return gatewayService.serverList(gatewayServerQueryBo);

    }
}
